package org.springframework.validation.executors;

import org.springframework.validation.util.ValidationRulesUtils;

/**
 * Returns as valid if model object is null or empty,
 * thereby performing an initial null check, and only validating
 * non-empty models.
 * @author cduplichien
 *
 */
public abstract class ValidWhenEmptyRuleExecutor implements RuleExecutor {

	public boolean validate(Object model, Object argument) {
		return ValidationRulesUtils.isEmpty(model) 
		|| doValidate(model, argument);
	}
	
	public abstract boolean doValidate(Object model, Object argument);
	
}
